#pragma once


#include <vector.h>
#include <stdio.h>
#include "NoteBox.h"


#include "GenericPlugin.h"


#define MAX_CHANNELS (10)


#ifndef M_PI
    #define M_PI  (3.14159265)
#endif


#include "portaudio.h"


class Sound
{
	public:
        void save();
        void load();

        vector<GenericPlugin*> plugins;
        vector<NoteBox> notes;
        unsigned int tempo;

        long startMarker;
        long endMarker;

        void * vpGlWindow;

        int totalChannels;

        Sound();

        unsigned long tickFractionToSamples( double x );

        void samplesToTime(unsigned long sampleLocation, long *bars, long *ticks, long *sampleOffset);
        void samplesToTicks(unsigned long sampleLocation, long *ticks, long *sampleOffset);
        unsigned long TicksToSamples(long ticks);
        void getEvents(int pluginIdIn, long startTick, long endTick, long endOffset);

        int openAudio();
        int closeAudio();

        unsigned long totalSamples;

  // This function is not intended for general use but had to be made
  // public for access from the audio callback function.
        void processBuffer( float *outputBuffer, unsigned long framesPerBuffer);
    private:
        long SAMPLE_RATE, FRAMES_PER_BUFFER, DEVICE, CHANNELS, CHANNEL_OFFSET;
        PaStream *stream;
        unsigned long framesPerBuffer;
};





